<h2>Disburse Profit </h2>
<hr>
<div id="#submitStatus">
</div>
<table id="disburseTable" cellspacing="10" cellpadding="10">
	<tr>
		<th> Agent Id </th>
		<th> Agent Name </th>
		<th> Registration Date </th>
		<th> </th>
	</tr>
<?php
	foreach($this->pending as $key => $value){
		echo '<tr id='.$value["agent_id"].'_'.$value["net_trans"].'>';
		echo '<td>'.$value['agent_reg_id'].'</td>';
		echo '<td>'.$value['agent_name'].'</td>';
		echo '<td>'.$value['rgrn_date'].'</td>';
		echo '<td>'.'<button name="disburse" tabindex="'.($key+1).'"  onclick="javascript:disburse('.$value['agent_id'].','.$value['net_trans'].');">Disburse</button>'.'</td>';
		echo '</tr>';
	}
?>
</table>

<script type="text/javascript" language="javascript">
var urlDisburse = "<?php echo $this->url(array('module'=>'admin','controller' => 'agent', 'action' => 'disburse'))?>";

function disburse(agent_id,trans) {
	$.ajax({
        url : urlDisburse,
        data : {'agent_id': agent_id, 'net_trans': trans },
        success: function(jStatus){
        	$('#'+agent_id+'_'+trans).hide('slow');
            $( "#submitStatus" ).text(jStatus).show( 'blind', '', 'slow');
        },
            error: function(response) {
          	  $('#errorBox').text(response.responseText).parent().show();
                console.log(response);
                }
            });
}

$(function() {
	$( "button" ).button({
        icons: {
            primary: "ui-icon-person"
        }
    });
});

</script>
